<template>
	<view>
		<u-toast ref="uToast" /><u-no-network></u-no-network>
		<u-navbar title="销售商申请状态" safeAreaInsetTop fixed placeholder>
			<view class="coreshop-navbar-left-slot" slot="left">
				<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
				<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
				<u-icon name="home" size="22" @click="goHome"></u-icon>
			</view>
			<view slot="right">
			</view>
		</u-navbar>
		<!--状态图标-->
		<view class="coreshop-status-image-view">
			<image :src="$globalConstVars.apiFilesUrl+'/static/images/common/non_real_name.png'" mode="widthFix"
				v-if="info.verifyStatus==3" />
			<image :src="$globalConstVars.apiFilesUrl+'/static/images/common/real_name.png'" mode="widthFix"
				v-if="info.verifyStatus==2 || info.verifyStatus==1" />
		</view>


		<view class="coreshop-text-black coreshop-font-lg coreshop-text-center coreshop-margin-bottom-10" v-if="status">
			<text class="coreshop-margin-right-10">{{info.name}}</text>
			<text>{{info.mobile}}</text>
		</view>

		<!--状态信息-->
		<view class="coreshop-text-black coreshop-font-xl coreshop-text-center coreshop-margin-bottom-10"
			v-if="info.verifyStatus==2">
			恭喜，您的申请已提交！
		
		</view>
		<view class="coreshop-text-black coreshop-font-xl coreshop-text-center coreshop-margin-bottom-10"
			v-if="info.verifyStatus==3">
			抱歉，您的申请被驳回！
		</view>
		<view class="coreshop-text-black coreshop-font-xl coreshop-text-center coreshop-margin-bottom-10"
			v-if="info.verifyStatus==1">
			恭喜，您的申请已通过！
		</view>

		<view class="coreshop-text-gray coreshop-text-center coreshop-padding-70" v-if="info.verifyStatus==2">
			您于{{info.createTime}}提交的申请已经提交成功，当前状态：<text v-if="info.verifyStatus==2">等待审核</text><text
				v-if="info.verifyStatus==3">审核驳回</text><text v-if="info.verifyStatus==1">审核通过</text>
		</view>

	<!-- 登录提示 -->
		<coreshop-login-modal></coreshop-login-modal>
		<u-button :custom-style="customStyle" type="error" size="normal" @click="goHome">进入商城</u-button>
	</view>

</template>
<script>
	import {
		mapState
	} from 'vuex';
	
	export default {
		data() {
			return {
				info: {}
			}
		},
		onLoad: function() {
			var _this = this;
			_this.initData();
		},
		watch: {
			hasLogin() {
				if (this.hasLogin == true) {
					this.getUserInfo();
				}
			}
		},
		computed: {
			...mapState({
				hasLogin: state => state.hasLogin,
				userInfo: state => state.userInfo,
			}),
			InvoiceSwitch() {
				return this.$store.state.config.invoiceSwitch || 2;
			},
			hasLogin: {
				get() {
					return this.$store.state.hasLogin;
				},
				set(val) {
					this.$store.commit('hasLogin', val);
				}
			},
			userInfo: {
				get() {
					return this.$store.state.userInfo;
				},
				set(val) {
					this.$store.commit('userInfo', val);
				}
			},
			pointShowName() {
				return this.$store.state.config.pointShowName
			},
		    // 获取vuex中状态
		    maxUploadImg() {
		        return this.$store.state.config.imageMax
		    }
		},
		methods: {
			
			submit() {
				uni.navigateTo({
				    url: '/pages/index/default/default'
				})
			},
			initData() {
				var _this = this
				_this.getUserInfo();
			},
			getUserInfo() { 
				var _this = this
				if (this.$db.get('userToken')) {
					this.hasLogin = true
					this.$u.api.userInfo().then(res => {
						if (res.status) {
                            _this.getDearInfo();
						} else {
							this.hasLogin = false;
							this.userInfo = null;
							this.$store.commit('showLoginTip', true);
						}
					})
				} else {
					this.hasLogin = false;
					this.$store.commit('showLoginTip', true);
				}
			},
			getDearInfo(){
				var _this = this;
				_this.$u.api.getDealerInfo({
					check_condition: true
				}).then(res => {
					if (res.status) {
						if (res.data.needApply && res.data.conditionStatus == false) {
							_this.$u.route({
								type: 'redirectTo',
								url: '/pages/member/dealer/index/index'
							});
						}
						if (res.data.verifyStatus == 1) { //审核通过
							_this.$u.route({
								type: 'redirectTo',
								url: '/pages/member/dealer/index/index'
							});
						}
						if (res.data.verifyStatus == 0 && res.data.needApply && res.data.conditionStatus ==
							true) { //审核通过
							_this.$u.route({
								type: 'redirectTo',
								url: '/pages/member/dealer/apply/apply'
							});
						}
						_this.info = res.data;
					} else {
						//报错了
						_this.$u.toast(res.msg);
					}
				});
			}
		}
	}
</script>
<style lang="scss">
	@import "applyState.scss";
</style>